#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Licensed under the GNU General Public License, version 3.
# See the file http://www.gnu.org/licenses/gpl.txt
from inary.actionsapi import inarytools
from inary.actionsapi import shelltools
from inary.actionsapi import autotools as tools
from inary.actionsapi import get

# Common X11 library build actions.py file

def setup():
    if get.buildTYPE() == "emul32":
        shelltools.export("CC","gcc -m32")
        shelltools.export("CXX","g++ -m32")
        shelltools.reset_env()
        shelltools.export("PKG_CONFIG_PATH","/usr/lib32/pkgconfig")
        tools.configure("--libdir=/usr/lib32/X11")
    else:
        shelltools.reset_env()
        tools.configure("--libdir=/usr/lib/X11")

def build():
    tools.make()

def install():
    tools.rawInstall("DESTDIR=%s" % get.installDIR())
    if get.buildTYPE() == "emul32":
        if shelltools.isDirectory("{}/usr/lib32/X11/pkgconfig".format(get.installDIR())):
            inarytools.domove("/usr/lib32/X11/pkgconfig","/usr/lib32")
    else:
        if shelltools.isDirectory("{}/usr/lib/X11/pkgconfig".format(get.installDIR())):
            inarytools.domove("/usr/lib/X11/pkgconfig","/usr/lib")
